<template>
  <div class="index">
    <div class="header">
      <top :username="uname"></top>
    </div>
    <div class="con clearfix">
      <div class="left">
        <ul>
          <mtree v-for="(mdata,key) in menuList" :key="key" :item="mdata"></mtree>
        </ul>
      </div>
      <div class="right">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script>
import top from '@/components/top.vue'
import mtree from '@/components/tree.vue'
import axios from 'axios'

export default {
  name: 'appview',
  components: { top, mtree },
  data () {
    return {
      uname: sessionStorage.getItem('userName'),
      menuList: [],
      isOpen: false
    }
  },
  mounted () {
    let $this = this
    axios.get('/api/menu')
      .then(function (res) {
        if (res.status === 200) {
          $this.menuList = res.data
        }
      })
      .catch(function (err) {
        console.log(err)
      })
  }
}
</script>

<style scope>
.index {
  width: 100%;
  height: 100%;
}
.header {
  height: 50px;
  background-color: #616161;
  color: #fff;
}
.con {
  width: 100%;
  height: calc(100% - 50px);
}
.left {
  float: left;
  width: 180px;
  height: 100%;
  background-color: #3a3a3a;
  box-sizing: border-box;
}
.right {
  float: left;
  width: calc(100% - 180px);
  height: 100%;
  box-sizing: border-box;
  padding: 10px;
  overflow-y: scroll;
  background-color:rgb(250, 250, 250);
}
</style>
